using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace LazyPlugins.AutoAttacher.UI
{
    public partial class Options : Form
    {
        public Options(string processName, int waitTimeout)
        {
            InitializeComponent();
            this.txtProcessName.Text = processName;
            this.udWaitTimeout.Value = waitTimeout;
        }

        public string ProcessName
        {
            get { return this.txtProcessName.Text; }
        }

        public int WaitTimeout
        {
            get { return (int)this.udWaitTimeout.Value; }
        }
        private void ProcessName_Validating(object sender, CancelEventArgs e)
        {
            Control control = sender as Control;
            if(String.IsNullOrEmpty(control.Text))
                errorProvider1.SetError(control,"Invalid process name");

        }

        private void Options_Load(object sender, EventArgs e)
        {
            errorProvider1.Clear();
        }

        private void Options_FormClosing(object sender, FormClosingEventArgs e)
        {
            if(!String.IsNullOrEmpty(errorProvider1.GetError(txtProcessName)))
            {
                MessageBox.Show(errorProvider1.GetError(txtProcessName),"Process Attacher");
                e.Cancel = true;
            }
        }
    }
}